
#include "processing.h"

static QPoint m_backPoint = QPoint(-1, -1);
static QPoint m_startP = QPoint(-1, -1);       //记录起点
static QPoint m_nextP = QPoint(-1, -1);        //记录变化的点
static QPoint m_regionStartP = QPoint(-1, -1); //记录框选起点
static QPoint m_regionEndP = QPoint(-1, -1);   //记录框选终点
static bool m_isReleasePaint = true;           //释放后翻转

processing::processing()
{

}


QImage processing::pictureCutDeepen(const QImage &img, const QSize &imageSize)
{
    QImage image = img.copy();
    int key = PICTURE_DEEPEN_KEY;

    for (int j = 0; j < image.height(); ++j) {
        for (int i = 0; i < image.width(); ++i) {
            QColor color(image.pixelColor(i, j));
            if (!color.alpha()) { //透明区域40%透明度的黑色
                color.setAlphaF(0.4);
                image.setPixel(i, j, color.rgba());
                continue;
            }

            color.setRed(minNumIsZero(color.red(), key));
            color.setGreen(minNumIsZero(color.green(), key));
            color.setBlue(minNumIsZero(color.blue(), key));
            image.setPixel(i, j, color.rgb());
        }
    }
    return image;
}



int processing::minNumIsZero(const int &num1, const int &num2)
{
    int num = num1 - num2;
    if (num < 0) {
        return 0;
    }
    return num;
}


